﻿using System;

namespace RecruitmentAgency.Models.DataTypes
{
    /// <summary>
    /// The RecruitmentAgency.Models.Cv.DataTypes.PersonEmployment contains individual employment details that belong to the user whose ID number is specified with the PersonId property
    /// </summary>
    public class PersonEmployment
    {
        /// <summary>
        /// Gets or sets the ID number of the employment record
        /// </summary>
        public int EmploymentId { get; set; }

        /// <summary>
        /// Gets or sets the ID number of the user that the employment record relates to
        /// </summary>
        public int PersonId { get; set; }

        /// <summary>
        /// Gets or sets the name of the company of the employment record
        /// </summary>
        public string CompanyName { get; set; }

        /// <summary>
        /// Gets or sets the name of the industry sector of the employment record
        /// </summary>
        public string IndustrySector { get; set; }

        /// <summary>
        /// Gets or sets the job title of the employment record
        /// </summary>
        public string JobTitle { get; set; }

        /// <summary>
        /// Gets or sets the employment start date of the employment record
        /// </summary>
        public string StartDate { get; set; }

        /// <summary>
        /// Gets or sets the employment end date of the employment record
        /// </summary>
        public string EndDate { get; set; }

        /// <summary>
        /// Gets or sets the job description of the employment record
        /// </summary>
        public string KeyDuties { get; set; }

        /// <summary>
        /// Gets or sets a Boolean value that determines whether the employment record has been verified
        /// </summary>
        public bool EmploymentVerified { get; set; }

        /// <summary>
        /// Gets or sets the type of verification received for the employment record
        /// </summary>
        public string EmploymentVerificationType { get; set; }

        /// <summary>
        /// Gets a Boolean value that determines whether the RecruitmentAgency.Models.Cv.DataTypes.PersonEmployment is to be considered to be null
        /// </summary>
        public bool IsNull
        {
            get
            {
                return CompanyName == null && IndustrySector == null && JobTitle == null && KeyDuties == null;
            }
        }

        /// <summary>
        /// Returns a short summary of the employment record
        /// </summary>
        /// <returns>A short summary of the employment record</returns>
        public string ToShortString()
        {
            return string.Format(string.Format("{0} for {1} from {2} to {3} ({4}).", JobTitle, CompanyName, (DateTime.Parse(StartDate)).ToShortDateString(), (DateTime.Parse(EndDate)).ToShortDateString(), IndustrySector));
        }

        /// <summary>
        /// Returns a detailed summary of the employment record
        /// </summary>
        /// <returns>A detailed summary of the employment record</returns>
        public string ToLongString()
        {
            string word = JobTitle.ToLower().StartsWith("a") || JobTitle.ToLower().StartsWith("e") || JobTitle.ToLower().StartsWith("i") || JobTitle.ToLower().StartsWith("o") || JobTitle.ToLower().StartsWith("u") ? "an" : "a";
            return string.Format(string.Format("Worked as {0} {1} for {2} from {3} to {4} in the {5} sector.", word, JobTitle, CompanyName, (DateTime.Parse(StartDate)).ToLongDateString(), (DateTime.Parse(EndDate)).ToLongDateString(), IndustrySector));
        }
    }
}